#include "Constants.h"
#include "WaterParticle.h"
#include <GL/gl.h>

WaterParticle::WaterParticle()
{
	alive = false;
	xPos = 0;
	yPos = 0;
	zPos = 0;
	xVel = 0;
	yVel = 0;
	zVel = 0;
}

void WaterParticle::animate(float timeD)
{
	yVel -= GRAVITY * timeD;
	yPos += timeD * yVel;
	xPos += timeD * xVel;
	zPos += timeD * zVel;
}

void WaterParticle::render()
{
	glPushMatrix();
		glTranslatef(xPos, yPos, zPos);
		float scale = 0.15;
		glScalef(scale, scale, scale);
		//glBindTexture(GL_TEXTURE_2D, topTexture);
		glEnable(GL_BLEND);
			glBegin(GL_QUADS);
				glColor4f(0.3, 0.4, 0.8, 0.6);
				
				//vertical face
				glVertex3f(-1, 3, 1);
				glVertex3f( 1, 3, 1);
				glVertex3f( 1,-3, 1);
				glVertex3f(-1,-3, 1);
				
				//horizontal face
				glVertex3f(-3, 1, 1);
				glVertex3f( 3, 1, 1);
				glVertex3f( 3,-1, 1);
				glVertex3f(-3,-1, 1);
				
//				//center face
//				glVertex3f(-1, 1, 1);
//				glVertex3f( 1, 1, 1);
//				glVertex3f( 1,-1, 1);
//				glVertex3f(-1,-1, 1);
//				
//				//right face
//				glVertex3f( 1, 1, 1);
//				glVertex3f( 3, 1, 1);
//				glVertex3f( 3,-1, 1);
//				glVertex3f( 1,-1, 1);
//				
//				//bottom face
//				glVertex3f(-1,-1, 1);
//				glVertex3f( 1,-1, 1);
//				glVertex3f( 1,-3, 1);
//				glVertex3f(-1,-3, 1);
				
			glEnd();
		glDisable(GL_BLEND);
	glPopMatrix();
	
}

void WaterParticle::testForAndHandleCollisions()
{
	if (yPos < 0)
	{
		alive = false;
	}
}
